package org.emet.dao;

import org.emet.entity.biz.BarCode;
import org.emet.jee.core.dao.Page;
import org.emet.jee.core.dao.arch.ArchDataSourceBaseDao;
import org.emet.service.dto.BarCodeCriteria;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class BarCodeDao extends ArchDataSourceBaseDao<BarCode, Long> {
	public Page<BarCode> search(Page<BarCode> page, BarCodeCriteria criteria) {
		Criteria c = getSession().createCriteria(BarCode.class);
		NonEmptyValueHashMap<String, Object> propertyNameValues = new NonEmptyValueHashMap<String, Object>();
		propertyNameValues.put("code", criteria.getCode());
		propertyNameValues.put("img", criteria.getImg());
		c.add(Restrictions.allEq(propertyNameValues));
		page.setOrderBy("id");
		page.setOrder("desc");
		return findPage(page, c);
	}
}
